<!doctype html>
<html lang="en">
<head>
    <title>Getting Started</title>
</head>
<body>
    <script src="../flowed.js" charset="utf-8"></script>
    <script>
        localStorage.debug = 'flowed:*';

        class Print {
          exec({ message }, context) {
            return new Promise((resolve, reject) => {

              let stop = false;
              context.counter++;
              if (context.counter === context.limit) {
                stop = true;
              }

              setTimeout(() => {
                console.log(message, context.counter);
                resolve(stop ? {} : { continue: true });
              }, 1000);
            });
          }
        }

        Flowed.FlowManager.run({
            tasks: {
              tick: {
                requires: ['continue'],
                provides: ['continue'],
                resolver: {
                  name: 'Print',
                  params: { message: { value: 'Tick' } },
                  results: { continue: 'continue' },
                }
              },
            },
          }, { continue: true }, [], { Print }, { counter: 0, limit: 5 },
        );
    </script>
</body>
</html>
